<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Hadoop伪分布式环境配置与启动 | 时光荏苒</title><meta name="keywords" content="Hadoop,Linux"><meta name="author" content="Lancer代良晨"><meta name="copyright" content="Lancer代良晨"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta http-equiv="Cache-Control" content="no-transform"><meta http-equiv="Cache-Control" content="no-siteapp"><meta name="description" content="1. 环境准备在一台linux机器上，安装好hadoop运行环境，安装方式请查看：HADOOP运行环境搭建 2. 启动HDFS并运行MapReduce程序2.1. 配置集群1. 配置：hadoop-env.shLinux系统中获取JDK的安装路径： 12[root@ hadoop101 ~]# echo $JAVA_HOME&#x2F;opt&#x2F;module&#x2F;jdk1.8.0_144 编辑hadoop-env">
<meta property="og:type" content="article">
<meta property="og:title" content="Hadoop伪分布式环境配置与启动">
<meta property="og:url" content="https://lancerdai.gitee.io/2020/02/16/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E5%BC%8F%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE%E4%B8%8E%E5%90%AF%E5%8A%A8/index.html">
<meta property="og:site_name" content="时光荏苒">
<meta property="og:description" content="1. 环境准备在一台linux机器上，安装好hadoop运行环境，安装方式请查看：HADOOP运行环境搭建 2. 启动HDFS并运行MapReduce程序2.1. 配置集群1. 配置：hadoop-env.shLinux系统中获取JDK的安装路径： 12[root@ hadoop101 ~]# echo $JAVA_HOME&#x2F;opt&#x2F;module&#x2F;jdk1.8.0_144 编辑hadoop-env">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://p3.qhimg.com/bdr/__100/t012468d019e3ce466b.jpg">
<meta property="article:published_time" content="2020-02-16T11:54:24.000Z">
<meta property="article:modified_time" content="2020-10-03T13:55:35.603Z">
<meta property="article:author" content="Lancer代良晨">
<meta property="article:tag" content="Hadoop">
<meta property="article:tag" content="Linux">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://p3.qhimg.com/bdr/__100/t012468d019e3ce466b.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://lancerdai.gitee.io/2020/02/16/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E5%BC%8F%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE%E4%B8%8E%E5%90%AF%E5%8A%A8/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css"><script>var GLOBAL_CONFIG = { 
  root: '/',
  hexoversion: '5.1.1',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  ClickShowText: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  justifiedGallery: {
    js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
    css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
};

var saveToLocal = {
  set: function setWithExpiry(key, value, ttl) {
    const now = new Date()
    const expiryDay = ttl * 86400000
    const item = {
      value: value,
      expiry: now.getTime() + expiryDay,
    }
    localStorage.setItem(key, JSON.stringify(item))
  },

  get: function getWithExpiry(key) {
    const itemStr = localStorage.getItem(key)

    if (!itemStr) {
      return undefined
    }
    const item = JSON.parse(itemStr)
    const now = new Date()

    if (now.getTime() > item.expiry) {
      localStorage.removeItem(key)
      return undefined
    }
    return item.value
  }
}</script><script id="config_change">var GLOBAL_CONFIG_SITE = { 
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isSidebar: true,
  postUpdate: '2020-10-03 21:55:35'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(function () {
  window.activateDarkMode = function () {
    document.documentElement.setAttribute('data-theme', 'dark')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
    }
  }
  window.activateLightMode = function () {
    document.documentElement.setAttribute('data-theme', 'light')
    if (document.querySelector('meta[name="theme-color"]') !== null) {
      document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
    }
  }

  const autoChangeMode = 'false'
  const t = saveToLocal.get('theme')
  if (autoChangeMode === '1') {
    const isDarkMode = window.matchMedia('(prefers-color-scheme: dark)').matches
    const isLightMode = window.matchMedia('(prefers-color-scheme: light)').matches
    const isNotSpecified = window.matchMedia('(prefers-color-scheme: no-preference)').matches
    const hasNoSupport = !isDarkMode && !isLightMode && !isNotSpecified

    if (t === undefined) {
      if (isLightMode) activateLightMode()
      else if (isDarkMode) activateDarkMode()
      else if (isNotSpecified || hasNoSupport) {
        const now = new Date()
        const hour = now.getHours()
        const isNight = hour <= 6 || hour >= 18
        isNight ? activateDarkMode() : activateLightMode()
      }
      window.matchMedia('(prefers-color-scheme: dark)').addListener(function (e) {
        if (saveToLocal.get('theme') === undefined) {
          e.matches ? activateDarkMode() : activateLightMode()
        }
      })
    } else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else if (autoChangeMode === '2') {
    const now = new Date()
    const hour = now.getHours()
    const isNight = hour <= 6 || hour >= 18
    if (t === undefined) isNight ? activateDarkMode() : activateLightMode()
    else if (t === 'light') activateLightMode()
    else activateDarkMode()
  } else {
    if (t === 'dark') activateDarkMode()
    else if (t === 'light') activateLightMode()
  }
})()</script><meta name="generator" content="Hexo 5.1.1"></head><body><div id="mobile-sidebar"><div id="menu_mask"></div><div id="mobile-sidebar-menus"><div class="mobile_author_icon"><img class="avatar-img" src="/null" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="mobile_post_data"><div class="mobile_data_item is-center"><div class="mobile_data_link"><a href="/archives/"><div class="headline">文章</div><div class="length_num">13</div></a></div></div><div class="mobile_data_item is-center">      <div class="mobile_data_link"><a href="/tags/"><div class="headline">标签</div><div class="length_num">16</div></a></div></div><div class="mobile_data_item is-center">     <div class="mobile_data_link"><a href="/categories/"><div class="headline">分类</div><div class="length_num">8</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page" href="/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li><li><a class="site-page" href="/games/"><i class="fa-fw fas-game"></i><span> game</span></a></li><li><a class="site-page" href="/books/"><i class="fa-fw fas-books"></i><span> books</span></a></li><li><a class="site-page" href="/Gallery/"><i class="fa-fw fas-Gallery"></i><span> Gallery</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div></div></div></div><div id="body-wrap"><div id="sidebar"><i class="fas fa-arrow-right on" id="toggle-sidebar"></i><div class="sidebar-toc"><div class="sidebar-toc__title">目录</div><div class="sidebar-toc__progress"><span class="progress-notice">你已经读了</span><span class="progress-num">0</span><span class="progress-percentage">%</span><div class="sidebar-toc__progress-bar">     </div></div><div class="sidebar-toc__content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#1-%E7%8E%AF%E5%A2%83%E5%87%86%E5%A4%87"><span class="toc-number">1.</span> <span class="toc-text">1. 环境准备</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#2-%E5%90%AF%E5%8A%A8HDFS%E5%B9%B6%E8%BF%90%E8%A1%8CMapReduce%E7%A8%8B%E5%BA%8F"><span class="toc-number">2.</span> <span class="toc-text">2. 启动HDFS并运行MapReduce程序</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#2-1-%E9%85%8D%E7%BD%AE%E9%9B%86%E7%BE%A4"><span class="toc-number">2.1.</span> <span class="toc-text">2.1. 配置集群</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E9%85%8D%E7%BD%AE%EF%BC%9Ahadoop-env-sh"><span class="toc-number">2.1.0.1.</span> <span class="toc-text">1. 配置：hadoop-env.sh</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E9%85%8D%E7%BD%AE%EF%BC%9Acore-site-xml"><span class="toc-number">2.1.0.2.</span> <span class="toc-text">2. 配置：core-site.xml</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E9%85%8D%E7%BD%AE%EF%BC%9Ahdfs-site-xml"><span class="toc-number">2.1.0.3.</span> <span class="toc-text">3. 配置：hdfs-site.xml</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-2-%E5%90%AF%E5%8A%A8%E9%9B%86%E7%BE%A4"><span class="toc-number">2.2.</span> <span class="toc-text">2.2 启动集群</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E6%A0%BC%E5%BC%8F%E5%8C%96NameNode%EF%BC%88%E7%AC%AC%E4%B8%80%E6%AC%A1%E5%90%AF%E5%8A%A8%E6%97%B6%E6%A0%BC%E5%BC%8F%E5%8C%96%EF%BC%8C%E4%BB%A5%E5%90%8E%E5%B0%B1%E4%B8%8D%E8%A6%81%E6%80%BB%E6%A0%BC%E5%BC%8F%E5%8C%96%EF%BC%89"><span class="toc-number">2.2.0.1.</span> <span class="toc-text">1. 格式化NameNode（第一次启动时格式化，以后就不要总格式化）</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%90%AF%E5%8A%A8NameNode"><span class="toc-number">2.2.0.2.</span> <span class="toc-text">2. 启动NameNode</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%90%AF%E5%8A%A8DataNode"><span class="toc-number">2.2.0.3.</span> <span class="toc-text">2. 启动DataNode</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-3-%E9%AA%8C%E8%AF%81%E9%9B%86%E7%BE%A4"><span class="toc-number">2.3.</span> <span class="toc-text">2.3 验证集群</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E6%9F%A5%E7%9C%8B%E6%98%AF%E5%90%A6%E5%90%AF%E5%8A%A8%E6%88%90%E5%8A%9F"><span class="toc-number">2.3.0.1.</span> <span class="toc-text">1. 查看是否启动成功</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E7%BD%91%E9%A1%B5%E6%9F%A5%E7%9C%8BNameNode%E7%9A%84%E7%95%8C%E9%9D%A2"><span class="toc-number">2.3.0.2.</span> <span class="toc-text">2. 网页查看NameNode的界面</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-4-%E6%93%8D%E4%BD%9C%E9%9B%86%E7%BE%A4"><span class="toc-number">2.4.</span> <span class="toc-text">2.4 操作集群</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%9C%A8HDFS%E4%B8%8A%E5%88%9B%E5%BB%BA%E6%96%87%E4%BB%B6%E5%A4%B9-user-lancer-input"><span class="toc-number">2.4.0.1.</span> <span class="toc-text">1. 在HDFS上创建文件夹&#x2F;user&#x2F;lancer&#x2F;input</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%B0%86%E6%B5%8B%E8%AF%95%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0%E5%88%B0%E9%9B%86%E7%BE%A4%E4%B8%8A%EF%BC%8C%E8%BF%99%E9%87%8C%E5%8F%AF%E4%BB%A5%E7%9B%B4%E6%8E%A5%E4%BD%BF%E7%94%A8Hadoop%E7%9A%84README-txt%E6%96%87%E4%BB%B6"><span class="toc-number">2.4.0.2.</span> <span class="toc-text">2. 将测试文件上传到集群上，这里可以直接使用Hadoop的README.txt文件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E8%BF%90%E8%A1%8CMapReduce%E7%A8%8B%E5%BA%8F"><span class="toc-number">2.4.0.3.</span> <span class="toc-text">3. 运行MapReduce程序</span></a></li></ol></li></ol></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#3-%E5%90%AF%E5%8A%A8YARN%E5%B9%B6%E8%BF%90%E8%A1%8CMapReduce%E7%A8%8B%E5%BA%8F"><span class="toc-number">3.</span> <span class="toc-text">3.  启动YARN并运行MapReduce程序</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#3-1-%E9%85%8D%E7%BD%AE%E9%9B%86%E7%BE%A4"><span class="toc-number">3.1.</span> <span class="toc-text">3.1 配置集群</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E9%85%8D%E7%BD%AEyarn-env-sh%E5%92%8Cmapred-env-sh"><span class="toc-number">3.1.0.1.</span> <span class="toc-text">1. 配置yarn-env.sh和mapred-env.sh</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E9%85%8D%E7%BD%AEyarn-site-xml"><span class="toc-number">3.1.0.2.</span> <span class="toc-text">2. 配置yarn-site.xml</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E9%85%8D%E7%BD%AEmapred-site-xml-%E9%9C%80%E8%A6%81%E5%B0%86mapred-site-xml-template%E9%87%8D%E6%96%B0%E5%91%BD%E5%90%8D%E4%B8%BAmapred-site-xml"><span class="toc-number">3.1.0.3.</span> <span class="toc-text">3. 配置mapred-site.xml (需要将mapred-site.xml.template重新命名为mapred-site.xml )</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-2-%E5%90%AF%E5%8A%A8yarn"><span class="toc-number">3.2.</span> <span class="toc-text">3.2 启动yarn</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%90%AF%E5%8A%A8%E5%89%8D%E5%BF%85%E9%A1%BB%E4%BF%9D%E8%AF%81NameNode%E5%92%8CDataNode%E5%B7%B2%E7%BB%8F%E5%90%AF%E5%8A%A8"><span class="toc-number">3.2.0.1.</span> <span class="toc-text">1. 启动前必须保证NameNode和DataNode已经启动</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%90%AF%E5%8A%A8ResourceManager"><span class="toc-number">3.2.0.2.</span> <span class="toc-text">2. 启动ResourceManager</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E5%90%AF%E5%8A%A8NodeManager"><span class="toc-number">3.2.0.3.</span> <span class="toc-text">3. 启动NodeManager</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-3-%E9%AA%8C%E8%AF%81%E9%9B%86%E7%BE%A4"><span class="toc-number">3.3.</span> <span class="toc-text">3.3 验证集群</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E9%AA%8C%E8%AF%81%E5%90%AF%E5%8A%A8%E6%88%90%E5%8A%9F"><span class="toc-number">3.3.0.1.</span> <span class="toc-text">1. 验证启动成功</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E7%BD%91%E9%A1%B5%E6%9F%A5%E7%9C%8Byarn%E9%A1%B5%E9%9D%A2"><span class="toc-number">3.3.0.2.</span> <span class="toc-text">2. 网页查看yarn页面</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-4-%E9%9B%86%E7%BE%A4%E6%93%8D%E4%BD%9C"><span class="toc-number">3.4.</span> <span class="toc-text">3.4 集群操作</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-5-%E9%85%8D%E7%BD%AE%E5%8E%86%E5%8F%B2%E6%9C%8D%E5%8A%A1%E5%99%A8"><span class="toc-number">3.5.</span> <span class="toc-text">3.5 配置历史服务器</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E9%85%8D%E7%BD%AEyarn-site-xml"><span class="toc-number">3.5.0.1.</span> <span class="toc-text">1. 配置yarn-site.xml</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E5%90%AF%E5%8A%A8%E5%8E%86%E5%8F%B2%E6%9C%8D%E5%8A%A1%E5%99%A8"><span class="toc-number">3.5.0.2.</span> <span class="toc-text">2. 启动历史服务器</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E6%9F%A5%E7%9C%8B%E6%98%AF%E5%90%A6%E5%90%AF%E5%8A%A8%E6%88%90%E5%8A%9F"><span class="toc-number">3.5.0.3.</span> <span class="toc-text">3. 查看是否启动成功</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#4-%E6%9F%A5%E7%9C%8BMR%E4%BB%BB%E5%8A%A1%E8%AF%A6%E7%BB%86%E5%8E%86%E5%8F%B2%E4%BF%A1%E6%81%AF"><span class="toc-number">3.5.0.4.</span> <span class="toc-text">4. 查看MR任务详细历史信息</span></a></li></ol></li></ol></li></ol></li></ol></div></div></div><header class="post-bg" id="page-header" style="background-image: url(http://p3.qhimg.com/bdr/__100/t012468d019e3ce466b.jpg)"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">时光荏苒</a></span><span id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page" href="/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page" href="/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li><li><a class="site-page" href="/games/"><i class="fa-fw fas-game"></i><span> game</span></a></li><li><a class="site-page" href="/books/"><i class="fa-fw fas-books"></i><span> books</span></a></li><li><a class="site-page" href="/Gallery/"><i class="fa-fw fas-Gallery"></i><span> Gallery</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于我</span></a></div></div><span class="close" id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></span></span></nav><div id="post-info"><div id="post-title"><div class="posttitle">Hadoop伪分布式环境配置与启动</div></div><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2020-02-16T11:54:24.000Z" title="发表于 2020-02-16 19:54:24">2020-02-16</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2020-10-03T13:55:35.603Z" title="更新于 2020-10-03 21:55:35">2020-10-03</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E5%A4%A7%E6%95%B0%E6%8D%AE/">大数据</a></span></div><div class="meta-secondline"> <span class="post-meta-separator">|</span><span class="post-meta-pv-cv"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout_post" id="content-inner"><article id="post"><div class="post-content" id="article-container"><h1 id="1-环境准备"><a href="#1-环境准备" class="headerlink" title="1. 环境准备"></a>1. 环境准备</h1><p>在一台linux机器上，安装好hadoop运行环境，安装方式请查看：<a target="_blank" rel="noopener" href="https://www.jianshu.com/p/c64f86c89500">HADOOP运行环境搭建</a></p>
<h1 id="2-启动HDFS并运行MapReduce程序"><a href="#2-启动HDFS并运行MapReduce程序" class="headerlink" title="2. 启动HDFS并运行MapReduce程序"></a>2. 启动HDFS并运行MapReduce程序</h1><h2 id="2-1-配置集群"><a href="#2-1-配置集群" class="headerlink" title="2.1. 配置集群"></a>2.1. 配置集群</h2><h4 id="1-配置：hadoop-env-sh"><a href="#1-配置：hadoop-env-sh" class="headerlink" title="1. 配置：hadoop-env.sh"></a>1. 配置：hadoop-env.sh</h4><p>Linux系统中获取JDK的安装路径：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">[root@ hadoop101 ~]# echo $JAVA_HOME</span><br><span class="line">/opt/module/jdk1.8.0_144</span><br></pre></td></tr></table></figure>
<p>编辑hadoop-env.sh，修改hadoop-env.sh中的JAVA_HOME 路径：</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">export JAVA_HOME=/opt/module/jdk1.8.0_144</span><br></pre></td></tr></table></figure>
<h4 id="2-配置：core-site-xml"><a href="#2-配置：core-site-xml" class="headerlink" title="2. 配置：core-site.xml"></a>2. 配置：core-site.xml</h4><p>首先文件的存取目录不能停留在本地，要用HDFS上的文件，就需要配置HDFS的NameNode的地址。<br>所以需要在core-site.xml中增加以下配置</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 指定HDFS中NameNode的地址 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">name</span>&gt;</span>fs.defaultFS<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line"> <span class="tag">&lt;<span class="name">value</span>&gt;</span>hdfs://hadoop101:9000<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 指定Hadoop运行时产生文件的存储目录 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line"> <span class="tag">&lt;<span class="name">name</span>&gt;</span>hadoop.tmp.dir<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line"> <span class="tag">&lt;<span class="name">value</span>&gt;</span>/opt/module/hadoop-2.7.2/data/tmp<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p><code>注意：地址中的hadoop101需要改为本地linux的IP地址或者主机名</code><br><code>hadoop.tmp.dir可以不配置，会默认将HDFS文件存储到/tmp目录下</code></p>
</blockquote>
<h4 id="3-配置：hdfs-site-xml"><a href="#3-配置：hdfs-site-xml" class="headerlink" title="3. 配置：hdfs-site.xml"></a>3. 配置：hdfs-site.xml</h4><p>因为伪分布式只有一个节点，所以需要把HDFS副本数量改为1（默认是3），需要在hdfs-site.xm中增加以下配置：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 指定HDFS副本的数量 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line"> <span class="tag">&lt;<span class="name">name</span>&gt;</span>dfs.replication<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line"> <span class="tag">&lt;<span class="name">value</span>&gt;</span>1<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h2 id="2-2-启动集群"><a href="#2-2-启动集群" class="headerlink" title="2.2 启动集群"></a>2.2 启动集群</h2><h4 id="1-格式化NameNode（第一次启动时格式化，以后就不要总格式化）"><a href="#1-格式化NameNode（第一次启动时格式化，以后就不要总格式化）" class="headerlink" title="1. 格式化NameNode（第一次启动时格式化，以后就不要总格式化）"></a>1. 格式化NameNode（第一次启动时格式化，以后就不要总格式化）</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]$ bin/hdfs namenode -format</span><br></pre></td></tr></table></figure>
<h4 id="2-启动NameNode"><a href="#2-启动NameNode" class="headerlink" title="2. 启动NameNode"></a>2. 启动NameNode</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]# sbin/hadoop-daemon.sh start namenode</span><br><span class="line">starting namenode, logging to /opt/module/hadoop-2.7.2/logs/hadoop-root-namenode-hadoop101.out</span><br><span class="line">[root@hadoop101 hadoop-2.7.2]# </span><br></pre></td></tr></table></figure>
<h4 id="2-启动DataNode"><a href="#2-启动DataNode" class="headerlink" title="2. 启动DataNode"></a>2. 启动DataNode</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]# sbin/hadoop-daemon.sh start datanode</span><br><span class="line">starting datanode, logging to /opt/module/hadoop-2.7.2/logs/hadoop-root-datanode-hadoop101.out</span><br><span class="line">[root@hadoop101 hadoop-2.7.2]# </span><br></pre></td></tr></table></figure>
<h2 id="2-3-验证集群"><a href="#2-3-验证集群" class="headerlink" title="2.3 验证集群"></a>2.3 验证集群</h2><h4 id="1-查看是否启动成功"><a href="#1-查看是否启动成功" class="headerlink" title="1. 查看是否启动成功"></a>1. 查看是否启动成功</h4><p>执行命令jps，结果如下图所示，这说明nameNode和dataNode都已经启动成功</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]# jps</span><br><span class="line">5584 DataNode</span><br><span class="line">5671 Jps</span><br><span class="line">5496 NameNode</span><br><span class="line">[root@hadoop101 hadoop-2.7.2]# </span><br></pre></td></tr></table></figure>
<h4 id="2-网页查看NameNode的界面"><a href="#2-网页查看NameNode的界面" class="headerlink" title="2. 网页查看NameNode的界面"></a>2. 网页查看NameNode的界面</h4><p>在浏览器输入网址：<a target="_blank" rel="noopener" href="http://hadoop101:50070/%EF%BC%8C%E5%8D%B3%E5%8F%AF%E7%99%BB%E5%BD%95%E5%88%B0NameNode%E7%95%8C%E9%9D%A2%EF%BC%8C%E5%8F%AF%E4%BB%A5%E6%9F%A5%E7%9C%8BHDFS%E9%9B%86%E7%BE%A4%E7%9A%84%E8%BF%90%E8%A1%8C%E7%8A%B6%E6%80%81%E5%92%8C%E6%96%87%E4%BB%B6%E3%80%82">http://hadoop101:50070/，即可登录到NameNode界面，可以查看HDFS集群的运行状态和文件。</a><br><code>注意：域名要换成你自己的linux机器域名或者机器IP地址，如果无法访问，可能是防火墙没关</code></p>
<h2 id="2-4-操作集群"><a href="#2-4-操作集群" class="headerlink" title="2.4 操作集群"></a>2.4 操作集群</h2><p>集群启动成功后，就可以操作hdfs，包括创建目录、上传文件、删除文件、执行MR任务等。下面再测试一下，MR任务在HDFS上执行的效果。</p>
<h4 id="1-在HDFS上创建文件夹-user-lancer-input"><a href="#1-在HDFS上创建文件夹-user-lancer-input" class="headerlink" title="1. 在HDFS上创建文件夹/user/lancer/input"></a>1. 在HDFS上创建文件夹/user/lancer/input</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]$ bin/hdfs dfs -mkdir -p /user/lancer/input</span><br></pre></td></tr></table></figure>
<p>操作结果：</p>
<img src="/images/Hadoop伪分布式环境配置与启动/1.png">
   

 

<h4 id="2-将测试文件上传到集群上，这里可以直接使用Hadoop的README-txt文件"><a href="#2-将测试文件上传到集群上，这里可以直接使用Hadoop的README-txt文件" class="headerlink" title="2. 将测试文件上传到集群上，这里可以直接使用Hadoop的README.txt文件"></a>2. 将测试文件上传到集群上，这里可以直接使用Hadoop的README.txt文件</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[atguigu@hadoop101 hadoop-2.7.2]$bin&#x2F;hdfs dfs -put README.txt &#x2F;user&#x2F;atguigu&#x2F;input&#x2F;</span><br></pre></td></tr></table></figure>
<p>操作结果：<br><img src="/images/Hadoop伪分布式环境配置与启动/2.png"></p>
   

 

<h4 id="3-运行MapReduce程序"><a href="#3-运行MapReduce程序" class="headerlink" title="3. 运行MapReduce程序"></a>3. 运行MapReduce程序</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]# bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount /user/lancer/input/ /user/lancer/output</span><br></pre></td></tr></table></figure>
<p>运行结果如下:<br><img src="/images/Hadoop伪分布式环境配置与启动/3.png"></p>
   

 

<p>可以在浏览器中下载输出文件，查看单词个数统计结果。</p>
<h1 id="3-启动YARN并运行MapReduce程序"><a href="#3-启动YARN并运行MapReduce程序" class="headerlink" title="3.  启动YARN并运行MapReduce程序"></a>3.  启动YARN并运行MapReduce程序</h1><h2 id="3-1-配置集群"><a href="#3-1-配置集群" class="headerlink" title="3.1 配置集群"></a>3.1 配置集群</h2><h4 id="1-配置yarn-env-sh和mapred-env-sh"><a href="#1-配置yarn-env-sh和mapred-env-sh" class="headerlink" title="1. 配置yarn-env.sh和mapred-env.sh"></a>1. 配置yarn-env.sh和mapred-env.sh</h4><p>两个文件中都把JAVA_HOME改为jdk8的路径，有的文件中export JAVA_HOME被注释掉了，需要取消注释</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">export JAVA_HOME=/opt/module/jdk1.8.0_144</span><br></pre></td></tr></table></figure>
<h4 id="2-配置yarn-site-xml"><a href="#2-配置yarn-site-xml" class="headerlink" title="2. 配置yarn-site.xml"></a>2. 配置yarn-site.xml</h4><p>编辑yarn-size.xml，增加如下配置项：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- Reducer获取数据的方式 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line"> 		<span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.nodemanager.aux-services<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line"> 		<span class="tag">&lt;<span class="name">value</span>&gt;</span>mapreduce_shuffle<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 指定YARN的ResourceManager的地址 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">name</span>&gt;</span>yarn.resourcemanager.hostname<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">value</span>&gt;</span>hadoop101<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h4 id="3-配置mapred-site-xml-需要将mapred-site-xml-template重新命名为mapred-site-xml"><a href="#3-配置mapred-site-xml-需要将mapred-site-xml-template重新命名为mapred-site-xml" class="headerlink" title="3. 配置mapred-site.xml (需要将mapred-site.xml.template重新命名为mapred-site.xml )"></a>3. 配置mapred-site.xml (需要将mapred-site.xml.template重新命名为mapred-site.xml )</h4><p>先将mapred-site.xml.template重新命名为mapred-site.xml</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop]$ mv mapred-site.xml.template mapred-site.xml</span><br></pre></td></tr></table></figure>
<p>然后在mapred-site.xml中增加以下配置项：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 指定MR运行在YARN上 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line"> <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapreduce.framework.name<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line"> <span class="tag">&lt;<span class="name">value</span>&gt;</span>yarn<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h2 id="3-2-启动yarn"><a href="#3-2-启动yarn" class="headerlink" title="3.2 启动yarn"></a>3.2 启动yarn</h2><h4 id="1-启动前必须保证NameNode和DataNode已经启动"><a href="#1-启动前必须保证NameNode和DataNode已经启动" class="headerlink" title="1. 启动前必须保证NameNode和DataNode已经启动"></a>1. 启动前必须保证NameNode和DataNode已经启动</h4><h4 id="2-启动ResourceManager"><a href="#2-启动ResourceManager" class="headerlink" title="2. 启动ResourceManager"></a>2. 启动ResourceManager</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]$ sbin/yarn-daemon.sh start resourcemanager</span><br></pre></td></tr></table></figure>
<h4 id="3-启动NodeManager"><a href="#3-启动NodeManager" class="headerlink" title="3. 启动NodeManager"></a>3. 启动NodeManager</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]$ sbin/yarn-daemon.sh start nodemanager</span><br></pre></td></tr></table></figure>
<h2 id="3-3-验证集群"><a href="#3-3-验证集群" class="headerlink" title="3.3 验证集群"></a>3.3 验证集群</h2><h4 id="1-验证启动成功"><a href="#1-验证启动成功" class="headerlink" title="1. 验证启动成功"></a>1. 验证启动成功</h4><p>执行jps，如果结果如下则说明启动成功。</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]# jps</span><br><span class="line">5584 DataNode</span><br><span class="line">6913 Jps</span><br><span class="line">6071 ResourceManager</span><br><span class="line">5496 NameNode</span><br><span class="line">6318 NodeManager</span><br><span class="line">[root@hadoop101 hadoop-2.7.2]# </span><br></pre></td></tr></table></figure>
<h4 id="2-网页查看yarn页面"><a href="#2-网页查看yarn页面" class="headerlink" title="2. 网页查看yarn页面"></a>2. 网页查看yarn页面</h4><p>在浏览器输入网址：<a target="_blank" rel="noopener" href="http://hadoop101:8088/">http://hadoop101:8088/</a>，即可登录到Yarn界面，可以查看任务运行状态。<br><code>注意：域名要换成你自己的linux机器域名或者机器IP地址，如果无法访问，可能是防火墙没关</code><br>页面如图所示：<br><img src="/images/Hadoop伪分布式环境配置与启动/4.png"></p>
   

 


<h2 id="3-4-集群操作"><a href="#3-4-集群操作" class="headerlink" title="3.4 集群操作"></a>3.4 集群操作</h2><ol>
<li>执行MapReduce程序（方法同上）<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]# bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar wordcount /user/lancer/input/ /user/lancer/output2</span><br></pre></td></tr></table></figure>
同样是执行MR程序，但是这次是由Yarn统一调配的，就能在yarn的界面上看到任务执行的进度，和任务的详细信息，如下图所示：<img src="/images/Hadoop伪分布式环境配置与启动/5.png">
   

 

</li>
</ol>
<h2 id="3-5-配置历史服务器"><a href="#3-5-配置历史服务器" class="headerlink" title="3.5 配置历史服务器"></a>3.5 配置历史服务器</h2><p>虽然能看到任务的执行状态，但是现在返现点击history按钮时，网页无法打开，那是因为没有启动历史信息查看服务。<br><img src="/images/Hadoop伪分布式环境配置与启动/6.png"></p>
   

 

<h4 id="1-配置yarn-site-xml"><a href="#1-配置yarn-site-xml" class="headerlink" title="1. 配置yarn-site.xml"></a>1. 配置yarn-site.xml</h4><p>加入以下配置项：</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">&lt;!-- 历史服务器端地址 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">name</span>&gt;</span>mapreduce.jobhistory.address<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">value</span>&gt;</span>hadoop101:10020<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br><span class="line"><span class="comment">&lt;!-- 历史服务器web端地址 --&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">property</span>&gt;</span></span><br><span class="line"> <span class="tag">&lt;<span class="name">name</span>&gt;</span>mapreduce.jobhistory.webapp.address<span class="tag">&lt;/<span class="name">name</span>&gt;</span></span><br><span class="line"> <span class="tag">&lt;<span class="name">value</span>&gt;</span>hadoop101:19888<span class="tag">&lt;/<span class="name">value</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">property</span>&gt;</span></span><br></pre></td></tr></table></figure>
<h4 id="2-启动历史服务器"><a href="#2-启动历史服务器" class="headerlink" title="2. 启动历史服务器"></a>2. 启动历史服务器</h4><figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]$ sbin/mr-jobhistory-daemon.sh start historyserver</span><br></pre></td></tr></table></figure>
<h4 id="3-查看是否启动成功"><a href="#3-查看是否启动成功" class="headerlink" title="3. 查看是否启动成功"></a>3. 查看是否启动成功</h4><p>执行jps，如果出现JobHistoryServer则说明启动成功</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">[root@hadoop101 hadoop-2.7.2]# jps</span><br><span class="line">5584 DataNode</span><br><span class="line">7107 JobHistoryServer</span><br><span class="line">6071 ResourceManager</span><br><span class="line">5496 NameNode</span><br><span class="line">7145 Jps</span><br><span class="line">6318 NodeManager</span><br><span class="line">[root@hadoop101 hadoop-2.7.2]# </span><br></pre></td></tr></table></figure>
<h4 id="4-查看MR任务详细历史信息"><a href="#4-查看MR任务详细历史信息" class="headerlink" title="4. 查看MR任务详细历史信息"></a>4. 查看MR任务详细历史信息</h4><img src="/images/Hadoop伪分布式环境配置与启动/7.png">
   

 </div><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Lancer代良晨</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://lancerdai.gitee.io/2020/02/16/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E5%BC%8F%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE%E4%B8%8E%E5%90%AF%E5%8A%A8/">https://lancerdai.gitee.io/2020/02/16/Hadoop%E4%BC%AA%E5%88%86%E5%B8%83%E5%BC%8F%E7%8E%AF%E5%A2%83%E9%85%8D%E7%BD%AE%E4%B8%8E%E5%90%AF%E5%8A%A8/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://lancerdai.gitee.io" target="_blank">时光荏苒</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Hadoop/">Hadoop</a><a class="post-meta__tags" href="/tags/Linux/">Linux</a></div><div class="post_share"><div class="social-share" data-image="http://p3.qhimg.com/bdr/__100/t012468d019e3ce466b.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2020/02/17/Hadoop%E7%9A%84%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E4%B8%8E%E4%B8%89%E7%A7%8D%E8%BF%90%E8%A1%8C%E6%A8%A1%E5%BC%8F/"><img class="prev-cover" src="http://p1.qhimg.com/bdr/__100/t018eb997ba237f590f.jpg" onerror="onerror=null;src='/img/404.jpg'"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">Hadoop的配置文件与三种运行模式</div></div></a></div><div class="next-post pull-right"><a href="/2020/02/16/Hadoop%E7%9A%84%E5%8D%95%E6%9C%BA%E6%A8%A1%E5%BC%8F%E5%92%8C%E5%AE%98%E6%96%B9%E7%A4%BA%E4%BE%8B/"><img class="next-cover" src="http://p5.qhimg.com/bdr/__100/t016591fff7fda9d11f.jpg" onerror="onerror=null;src='/img/404.jpg'"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Hadoop的单机模式和官方示例</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span> 相关推荐</span></div><div class="relatedPosts-list"><div><a href="/2020/02/15/Hadoop运行环境搭建教程/" title="Hadoop运行环境搭建教程"><img class="cover" src="http://p1.qhimg.com/bdm/1600_900_85/t013777ac0e30cc6227.jpg"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-15</div><div class="title">Hadoop运行环境搭建教程</div></div></a></div><div><a href="/2020/02/16/Hadoop的单机模式和官方示例/" title="Hadoop的单机模式和官方示例"><img class="cover" src="http://p5.qhimg.com/bdr/__100/t016591fff7fda9d11f.jpg"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-16</div><div class="title">Hadoop的单机模式和官方示例</div></div></a></div><div><a href="/2020/02/17/Hadoop的配置文件与三种运行模式/" title="Hadoop的配置文件与三种运行模式"><img class="cover" src="http://p1.qhimg.com/bdr/__100/t018eb997ba237f590f.jpg"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-17</div><div class="title">Hadoop的配置文件与三种运行模式</div></div></a></div><div><a href="/2020/02/19/Java操作HDFS示例/" title="Java操作HDFS示例"><img class="cover" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-19</div><div class="title">Java操作HDFS示例</div></div></a></div><div><a href="/2020/02/13/VI和VIM的用法详解/" title="VI和VIM的用法详解"><img class="cover" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2020-02-13</div><div class="title">VI和VIM的用法详解</div></div></a></div></div></div></article></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 By Lancer代良晨</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><section id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></section><div><script src="https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js"></script><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js"></script><div class="js-pjax"><script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></div></body></html>